package com.xing.algorithm.array;

class RotateArray {
    public static void rotate(int[] nums, int k) {
        if(nums == null) {
            return;
        }

        if(k == 0) {
            return;
        }

        for(int i = 0; i < k; i ++) {

            int lastNum = nums[nums.length - 1];

            for(int j = nums.length - 2; j >= 0; j --) {
                    nums[j+1] = nums[j];
            }

            nums[0] = lastNum;
        }
    }

    public static void main(String[] args) {
        int[] nums = new int[]{1,2,3,4,5,6,7};
        rotate(nums, 3);

        for (int i = 0; i < nums.length; i++) {
            System.out.println(nums[i]);
        }

    }
}
